import request from '@/utils/request'

export function createCourse(data) {
  return request({
    url: '/api/course',
    method: 'post',
    data
  })
}

export function updateCourse(id, data) {
  return request({
    url: `/api/course/${id}`,
    method: 'put',
    data
  })
}

export function getCourseById(id) {
  return request({
    url: `/api/course/${id}`,
    method: 'get'
  })
}

export function deleteCourse(id) {
  return request({
    url: `/api/course/${id}`,
    method: 'delete'
  })
}

export function getCoursesByPage(params) {
  return request({
    url: '/api/course/page',
    method: 'get',
    params
  })
}

export function getHotCourses(limit) {
  return request({
    url: '/api/course/hot',
    method: 'get',
    params: { limit }
  })
}

export function incrementViewCount(id) {
  return request({
    url: `/api/course/${id}/view`,
    method: 'post'
  })
}

export function getCoursesByCategory(categoryId) {
  return request({
    url: '/api/course/category',
    method: 'get',
    params: { categoryId }
  })
} 